document.addEventListener("DOMContentLoaded", function () {
  const form = document.getElementById("xiaohongshu-search");
  const input = document.getElementById("search-keyword");
  const hintBox = document.getElementById("searchHint");
  const searchTermSpan = document.getElementById("searchTerm");

  form.addEventListener("submit", function (event) {
    event.preventDefault();
    const keyword = input.value.trim();
    if (keyword) {
      searchTermSpan.innerText = keyword;
      hintBox.style.display = "block";

      setTimeout(() => {
        const xhsUrl = `https://www.xiaohongshu.com/search_result?keyword=${encodeURIComponent(keyword)}`;
        window.open(xhsUrl, "_blank");
        hintBox.style.display = "none";
      }, 800);
    }
  });
});
